<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.scalar.forecast.commons.Constants"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/salesPersonSetup.do"/>

<html:html locale="true">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%> <%--try{ --%>
<% User user1 = (User) session.getAttribute (SessionKeys.USER_KEY); %>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<SCRIPT language="JavaScript">

 function submitPage(action)
 {
        var form = document.salesPersonSetupForm;

        if(action == 'level')
        {
            form.action.value = "Level";
        }
        if(action == 'salesperson')
        {
            form.action.value = "SalesPerson";
        }
        form.submit();
 }

 function saveSalesPerson()
 {
        var pa=document.getElementById("errors");
	    var valid = true;
        var salesperson = document.salesPersonSetupForm.existingSalesPersonId.value;
        var level       = document.salesPersonSetupForm.forecastLevelOrder.value;
        var userIdSelectedIdx = document.salesPersonSetupForm.existingUserIds.selectedIndex;
        pa.innerHTML="";
        if(salesperson == -1)
	    {
            valid = false;
            //document.salesPersonSetupForm.existingSalesPersonId.focus();
            pa.innerHTML = "<li> Please select a Sales Person";
            //location="#e1"
	    }
        if(level == -1)
	    {
            valid = false;
            //document.salesPersonSetupForm.forecastLevelOrder.focus();
            pa.innerHTML = pa.innerHTML+"<li> Please select a Level/Designation";
            //location="#e1"
	    }
        if(userIdSelectedIdx == -1)
	    {
            valid = false;
            //document.salesPersonSetupForm.existingUserId.focus();
            pa.innerHTML = pa.innerHTML+"<li> Please select an Existing User";
            //location="#e1"
	    }
        if(valid == true)
        {
            document.salesPersonSetupForm.action.value="Save";
            document.salesPersonSetupForm.submit();
        }
 }

</script>

<!-- Top Header Start-->

    <%
        String userTypeChiptrac = com.scalar.chiptrack.commons.Constants.USER_TYPE_CHIPTRAC + "";
    %>
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>
<!-- Top Header End-->
<html:form name="salesPersonSetupForm" type="com.scalar.chiptrack.forecast.salesPersonSetup.forms.SalesPersonSetupForm" action="/salesPersonSetup.do">

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
    <TBODY>
    <TR>
        <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
            <!-- Side Navigation start -->
            <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
                <%@ include file="/jsp/marketing/marketing_menu.jsp" %>
            </logic:equal>
            <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
                <%@ include file="/jsp/forecast/external_forecast_menu.jsp" %>
            </logic:notEqual>
            <!-- end of the side navigations -->
        </td>
        <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">
            <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
            <BR>
           <%-- <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20> --%>
              <TABLE border=0 width="90%" cellspacing="0" cellpadding="2" align="center">
                <TBODY>
                    <tr><td colspan='5' align="center" class="NArialW">Sales Person Setup</td></tr>
                    <tr><td colspan='5'><chiptrack:info styleClass="NArialL" />&nbsp;</td></tr>
                    <tr><td colspan='5'><chiptrack:errors styleClass="NArialL" />&nbsp;</td></tr>
                    <tr><td colspan='5' class='NArialL'><font styleClass="NArialL" id='errors' color="FF0000" /></td></tr>
                    <% if ( !user1.isActionAllowed ( Functionality.SALES_PERSON_SETUP,User.USER_ACTION_MODIFY ) ) { %>
                        <tr><td colspan=5 align='left'><font class='NArialS'><font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font></td></tr> <% } %>
                    <tr><td colspan='5' class='NArialL'>&nbsp;</td></tr>
					<TR>
						<TD width="20%" nowrap><FONT class=NArialL>Existing Sales Persons : </FONT></TD>

                        <TD width="20%" >
                            <html:select name="salesPersonSetupForm" property="existingSalesPersonId"  styleClass='txfield' onchange="javascript:submitPage('salesperson');">
                                <option value="-1" selected>-- Select Sales Person --</option>
                                <html:options collection="salesPersonList" property="value" labelProperty="label" />
                             </html:select>
   						</TD>
						<TD width="20%">&nbsp;</TD>
						<TD width="20%"><FONT class=NArialL>Level/Designation :</FONT></TD>
						<TD width="20%">
                            <html:select name="salesPersonSetupForm" property="forecastLevelOrder"  styleClass='txfield' onchange="javascript:submitPage('level');" >
                                    <option value="-1" selected>-- Select Level --</option>
                                    <html:options collection="levelList" property="value" labelProperty="label" />
                            </html:select>
                        </TD>
					</TR>
                    <tr>
                        <td colspan="5"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
                    </tr>
                    <TR>
						<TD width="20%" valign="top" class=NArialL> Manager : </TD>
						<TD width="20%" valign="top">
                            <html:select name="salesPersonSetupForm" property="managerId"  styleClass='txfield'  >
                                    <option value="-1" selected>-- Select Manager --</option>
                                    <bean:size id="ALSize" name="mgrList" />
                                    <logic:greaterThan name="ALSize" value="0">
                                    <html:options collection="mgrList" property="value" labelProperty="label" />
                                    </logic:greaterThan>
                            </html:select>
                        </TD>

                        <TD width="20%">&nbsp;</TD>
                        <TD width="20%" nowrap valign="top" class=NArialL>Map With Existing Users :</TD>
	                    <TD width="20%" valign="top">
                            <html:select name="salesPersonSetupForm" property="existingUserIds" styleClass="txfield" multiple="true" size="5">
                                <!--<option value="-1">-- Select User --</option>-->
                                <html:options collection="userList" property="value" labelProperty="label" />
                            </html:select>
                        </TD>
					</TR>

                    <tr><td colspan="5">&nbsp;</td></tr>

	             </TBODY>
             </TABLE>

                <table align="center">
                      <TR>

                        <td nowrap align='center' >
                        <chiptrack:restrictedLink functionality='<%=Functionality.SALES_PERSON_SETUP%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:saveSalesPerson();" onmouseover="window.status='Click to save Sales Person Setup';return true" onmouseout="window.status='';return true">
                            <img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"   title="Click to save Sales Person Setup ">
                        </chiptrack:restrictedLink>
                        </td>
                        <td>&nbsp;</td>
                        <td nowrap align="center">
                             <a href="javascript:document.salesPersonSetupForm.reset()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"  onMouseOver="window.status='Click  to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
                        </td>

                      </TR>
               </table>
               <logic:equal name="showList" value="true">
                <TABLE borderColor=#FFFFFF width="85%" align=center border=0>
                    <TR><TD colspan=4>&nbsp;</TD></TR>
                    <TR>
                        <TD align=middle width='25%' bgColor='#993333'><FONT class=NArialL><FONT color='#ffffff'>Sales Person Name </TD>
                        <TD align=middle width='25%' bgColor='#993333'><FONT class=NArialL><FONT color='#ffffff'>Level/Designation </TD>
                        <TD align=middle width='25%' bgColor='#993333'><FONT class=NArialL><FONT color='#ffffff'>Manager </TD>
                        <TD align=middle width='25%' bgColor='#993333'><FONT class=NArialL><FONT color='#ffffff'>User Id </TD>
                    </TR>

                        <% int bgcount=0;%>
                        <logic:iterate name="salesPersonsList" id="salesPerson">
                            <% bgcount++;%>
                            <TR>
                                <td width="25%" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><bean:write name="salesPerson" property="salesPersonName" /></font></td>
                                <td width="25%" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><bean:write name="salesPerson" property="level" /></font></td>
                                <td width="25%" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><bean:write name="salesPerson" property="manager" /></font></td>
                                <td width="25%" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL"><bean:write name="salesPerson" property="userName" /></font></td>
                            </TR>
                        </logic:iterate>
               </TABLE>
               </logic:equal>

      <BR><BR><BR></TD>
        <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
    </TR>
</TABLE>
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
<input type="hidden" name="action">
</html:form>
</BODY>
</html:html>